<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!-- 验证还是jquery-validation好用，这里省事没用 -->
<script>
function addOrUpdateUser(){
	var r = $('#aaaForm').form('validate');
	if(!r) {
		return false;
	}
	var url = "mad/madAdd";
	if($('#id').val()!='')
    {
		url = "mad/madUpdate";
    }
	$.post(url,$("#madForm").serializeArray(),function(data){
		$('#MyPopWindow').window('close');
		$('#madTable').datagrid('reload');  
		$.messager.alert('提示',data.mes,'info');
	});
};
var startdate = null;
$.extend($.fn.validatebox.defaults.rules, {
    loadVal: {
        validator: function(value){
        	startdate = value;
            return true;
        },
        message: '结束日期应该大于开始日期!'
    }
});
$.extend($.fn.validatebox.defaults.rules, {
    ge: {
        validator: function(value){
            return (value >= startdate);
        },
        message: '结束日期应该大于开始日期!'
    }
});
</script>
<form id="madForm" method="post" style="margin: 10;text-align: center;">
	<input type="hidden" name="version" value="${mad.version }">
	<input type="hidden" name="id" value="${mad.id }">
	<input type="hidden" name="delflg" value="${mad.delflg }">
	<input type="hidden" name="creatuserid" value="${mad.creatuserid }">
	<table>
		<tr>
			<td>有效期开始日：</td>
			<td><input validType="loadVal" name="startdate" value='<fmt:formatDate value="${mad.startdate }" pattern="yyyy-MM-dd"/>' readonly="readonly" style="width: 400"
				 class="easyui-datebox" required="true">
			</td>
		</tr>
		<tr>
			<td>有效期结束日：</td>
			<td><input validType="ge" name="enddate" value='<fmt:formatDate value="${mad.enddate }" pattern="yyyy-MM-dd"/>' readonly="readonly" style="width: 400"
				 class="easyui-datebox" required="true">
		</tr>
		<tr>
			<td>标题：</td>
			<td><input name="title" value="${mad.title }" style="width: 400"
				validType="length[2,100]" class="easyui-validatebox" required="true">
			</td>
		</tr>
		<tr>
			<td>内容：</td>
			<td>
				<textarea rows="" cols="" name="value" class="easyui-validatebox" required="true" style="width: 400px;height:100px;">${mad.value }</textarea>
			</td>
		</tr>
	</table>
	<a href="#" id="btn-back" onclick="closeWindow();" class="easyui-linkbutton" iconCls="icon-back">返回</a>
	<a href="#" id="btn-add" onclick="addOrUpdateUser();" class="easyui-linkbutton" iconCls="icon-save">保存</a>
</form>